﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using System.Data;
using KPIS.GERP.GHRMS.DAL;
using KPIS.GERP.GHRMS.MODEL;
using KPIS.GERP.GHRMS.IBLL;
using KPIS.GERP.GHRMS.IDAL;
using KPIS.GERP.GHRMS.DALFactory;

namespace KPIS.GERP.GHRMS.BLL
{
    public class NonWorkingDayBLL : INonWorkingDayBLL
    {
        private static readonly INonWorkingDayDAL DAL = DataAccess.CreateNonWorkingDays();

        private NonWorkingDayInfo Info = new NonWorkingDayInfo();

        public IList<NonWorkingDayInfo> GetAllNonWorkingDays(string bg_year)
        {
            return DAL.GetAllNonWorkingDays(bg_year);
        }

        public IList<NonWorkingDayInfo> ListNonWorkingDay(int BudgetYear, int Year, string Month, string Day)
        {
            Info.BudgetYear = BudgetYear;
            Info.Year = Year;
            Info.Month = Month.Length > 0 ? Int32.Parse(Month) : 0;
            Info.Day = Day.Length > 0 ? Int32.Parse(Day) : 0;
            return DAL.ListNonWorkingDay(Info);
        }
        
        public IList<NonWorkingDayInfo> ListNonWorkingDayBySequence(int Sequence)
        {
            return DAL.ListNonWorkingDay(new NonWorkingDayInfo(Sequence));
        }

        public int Insert(int BudgetYear, DateTime Date, string Name, string Remarks, int CreatedBy)
        {
            try
            {
               return  DAL.Insert(new NonWorkingDayInfo(0, BudgetYear, Date, Name, Remarks, "", CreatedBy, 0));
            }
            catch
            {
                throw new Exception("");
            }
        }
        public void Update(int Sequence, int BudgetYear, DateTime Date, string Name, string Remarks, int UpdatedBy)
        {
            try
            {
                DAL.Update(new NonWorkingDayInfo(Sequence, BudgetYear, Date, Name, Remarks, "", 0, UpdatedBy));
            }
            catch
            {
                throw new Exception("");
            }
        }
        public void Delete(int Sequence, int UpdatedBy)
        {
            try
            {
                DAL.Delete(Sequence, UpdatedBy);
            }
            catch
            {
                throw new Exception("");
            }
        }
    }
}
